package com.epam.kozich.dao;

import java.util.List;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import com.epam.kozich.model.Person;

public class PersonDAOImpl extends HibernateDaoSupport implements PersonDAO {
	
	SessionFactory sessionFactory;

	@Override
	public void addPerson(Person person) {
		getHibernateTemplate().save(person);
	}

	public void updatePerson(Person person) {
		getHibernateTemplate().update(person);
	}

	@Override
	public void deletePerson(Person person) {
		getHibernateTemplate().delete(person);

	}

	 @SuppressWarnings("unchecked")
	public List<Person> outputPerson() {
		return getHibernateTemplate().find("from Person");
		
	}

	@Override
	public List<Person> outputBannedPerson() {
		return getHibernateTemplate().find("from Person WHERE banned=true");
	}
	
}